<template>
  <div class="recruit">
    <h2 class="mytitle">学生会管理/审核学生会申请</h2>
    <div class="mycontent">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column
          fixed
          prop="department.depName"
          label="申请部门"
          width="120"
        >
        </el-table-column>
        <el-table-column fixed prop="user.name" label="姓名" width="80">
        </el-table-column>
        <el-table-column prop="user.sex" label="性别" width="80">
        </el-table-column>
        <el-table-column prop="user.phone" label="手机号" width="120">
        </el-table-column>
        <el-table-column prop="user.major.majorName" label="专业" width="80">
        </el-table-column>
        <el-table-column prop="user.hobby" label="爱好" width="200">
        </el-table-column>
        <el-table-column prop="department.depDesc" label="申请理由" width="300">
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="100">
          <template slot-scope="scope">
            <el-button @click="handleClick1(scope.row)" type="text" size="small"
              >通过</el-button
            >
            <el-button @click="handleClick2(scope.row)" type="text" size="small"
              >拒绝</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import Api from "../assets/js/api";
export default {
  data() {
    return {
      tableData: [],
    };
  },
  methods: {
    findall() {
      this.$http({
        url: Api.findby, //接口
        method: "POST", //请求方式 默认get
        headers: {
          JWTHeaderName: sessionStorage.getItem("token"),
        },
        data: {
          applyStatus: 1,
        }, // data数据
      }).then((res) => {
        // console.log(res.data.data);
        this.tableData = res.data.data;
        // console.log(this.tableData);
      });
    },
    handleClick1(row) {
      let that=this
      // 审核通过接口
      this.$http({
        url: Api.updatestatus, //接口
        method: "POST", //请求方式 默认get
        headers: {
          JWTHeaderName: sessionStorage.getItem("token"),
        },
        data: {
          applyStatus: 0,
          aid:row.aid
        }, // data数据
      }).then((res) => {
        console.log("审核通过");
        console.log(res);
        this.findall();
      });
    },
    handleClick2(row) {
      let that=this
      this.$http({
        url: Api.updatestatus, //接口
        method: "POST", //请求方式 默认get
        headers: {
          JWTHeaderName: sessionStorage.getItem("token"),
        },
        data: {
          applyStatus: -1,
          aid:row.aid
        }, // data数据
      }).then((res) => {
        console.log("审核不通过");
        console.log(res);
        this.findall();
      });
    },
  },
  mounted() {
    this.findall();
  },
};
</script>

<style scoped>
.mytitle {
  margin-top: 0;
}
.el-table .warning-row {
  background: oldlace;
}
</style>
